home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / cxxp4w.zip / CHAP03 / WINDOW.HPP < prev   
C/C++ Source or Header  |  1993-03-11  |  3KB  |  133 lines

  1. #ifndef    WINDOW_INC
  2. #define    WINDOW_INC
  3.  
  4. #include "winobj.hpp"
  5.  
  6. extern "C" {
  7. LONG CALLBACK CPPWinProc(HWND, UINT, UINT, LONG);
  8. }
  9.  
  10.  
  11. class Event {
  12.  
  13. public:
  14. UINT wParam;
  15. LONG lParam;
  16.  
  17. Event(UINT w, LONG l) {wParam=w; lParam=l;};
  18. }; // class Event
  19.  
  20. typedef struct {
  21.   int RepeatCount:16,
  22.       ScanCode:8,
  23.       fExtended:1,
  24.       reserved1:4,
  25.       fAlt:1,
  26.       fPrev:1,
  27.       fTransition:1;
  28. } KEYCODES;
  29.  
  30.  
  31. class Window: public  WinObj    {
  32. protected :
  33. //#ifdef WIN32
  34.  // WNDPROC DefaultHandler;
  35. //  static WNDPROC Handler;
  36. //#else
  37.   FARPROC DefaultHandler;    // default callback
  38.   static FARPROC Handler;    // proc instance
  39. //#endif
  40.   void SetHandler();
  41.   static HANDLE hAccel;
  42.  
  43. public:
  44.   Window();            // void constructor
  45.   ~Window();
  46.  
  47. protected:
  48.   void Create(                  // Create a window
  49.     LPSTR pCaption,             // Caption
  50.     LONG  Style,
  51.     int x,                      // Position
  52.     int y,
  53.     int width,                  // Size
  54.     int height,
  55.     HWND hPwnd,                 // Parent handle
  56.     HMENU hMenu=NULL);
  57.  
  58. public:    
  59.  
  60.   HWND hWnd;                    // Window handle
  61.  
  62.   friend  LONG CALLBACK CPPWinProc(
  63.     HWND hWnd, UINT msg, UINT wParam, LONG lParam);
  64.  
  65.   virtual int MessageLoop();
  66.   virtual LONG MessageProc(
  67.     HWND hWnd,
  68.     unsigned msg,
  69.     Event& evt);
  70.  
  71.   virtual LPSTR Register(WNDCLASS& wc);
  72.  
  73.   void Move(
  74.     RECT *rc,                   // Move the window
  75.     BOOL repaint=TRUE);
  76.  
  77.   BOOL Show(                    // Show or hide the window
  78.     int nCmdShow=SW_SHOW){
  79.     return ShowWindow(hWnd,nCmdShow);};
  80.  
  81.   int GetText(                  // Get window text
  82.     LPSTR pBuffer,
  83.     int Size){
  84.     return SendMessage(hWnd,WM_GETTEXT,Size,(LONG)pBuffer);};
  85.  
  86.   int SetText(                  // Set window text
  87.     LPSTR pBuffer){
  88.     return SendMessage(hWnd,WM_SETTEXT,0,(LONG)pBuffer);};
  89.  
  90. #ifdef __BORLANDC__
  91.   #pragma warn -par
  92. #endif                          // Virtual event methods
  93.   virtual BOOL  InitMenu(HMENU hMenu)
  94.     {return FALSE;};
  95.   virtual BOOL  QueryClose()
  96.     {return TRUE;};
  97.   virtual BOOL  Size( UINT Width, UINT Height, UINT Type);
  98.   virtual BOOL  Char(UINT Value, UINT Repeat)
  99.     {return FALSE;};
  100.   virtual BOOL  KeyDown(UINT VirtKey, KEYCODES KeyCodes)
  101.     {return FALSE;};
  102.   virtual BOOL  LButtonDown(POINT Cursor, UINT Keys)
  103.     {return FALSE;};
  104.   virtual BOOL  LButtonDblClk(POINT Cursor, UINT Keys)
  105.     {return FALSE;};
  106.   virtual BOOL  MouseMove(POINT Cursor, UINT Keys)
  107.     {return FALSE;};
  108.   virtual BOOL  MouseActivate(HWND hTop, UINT HitTest)
  109.     {return FALSE;};
  110.   virtual BOOL  LButtonUp(POINT Cursor, UINT Keys)
  111.     {return FALSE;};
  112.   virtual BOOL  RButtonDown(POINT Cursor, UINT Keys)
  113.     {return FALSE;};
  114.   virtual BOOL  RButtonUp(POINT Cursor, UINT Keys)
  115.     {return FALSE;};
  116.   virtual BOOL  Paint();
  117.   virtual BOOL  SetFocus (HWND hPrev)
  118.     {return FALSE;};
  119.   virtual BOOL  KillFocus (HWND hNext)
  120.     {return FALSE;};
  121.   virtual BOOL  Command( UINT Id, UINT Code, HWND hControl);
  122.  
  123. #ifdef __BORLANDC__
  124.   #pragma warn +par
  125. #endif
  126. }; // class Window
  127.  
  128. extern void PutWin(HWND hWnd, Window * pWin);
  129. extern Window * GetWin(HWND hWnd);
  130. extern Window * DelWin(HWND hWnd);
  131.  
  132. #endif // WINDOW_INC
  133.